<?php
include("../../tools/session.php");
include("../../tools/controls.php");

// 如果登录失败、无权限访问，那么采取相应措施
if (!($is_login_success === true)) { session_hop_page("../index.php"); exit(); }
if (!power_check(0)) { include("tpl-inc-wp.php"); $tpl->display($oa_tpl_path . "/no-power.html"); exit(); }

/*-- 以下是实际内容 --*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="utf-8">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Content-Language" content="UTF-8" />
	<meta content="all" name="robots" />
	<meta name="author" content="tiger"/>
	<meta name="Copyright" content="jinzhou group" />
	<meta name="description" content="jinzhou group oa" />
	<title>上传附件</title>
	<style>
	body { font-size: 10pt; }
	iframe { border:solid 1px #999; width: 380px; height:80px; }
	select { width: 280px; }
	</style>
	<script language="javascript" src="../js/jquery/jquery.js"></script>
<script language="javascript">
// 上传成功时调用的函数
function upload_file_succ(file)
{
  var filename = get_filename(file);
  var str = "<option value=\"" + file + "\">" + filename + "</option>";
  $("#file_list").append(str);
}
// 获取一个路径中的文件名
function get_filename(file)
{
  var a = file.split("/");
  return a[a.length - 1];
}
// 删除上传的文件
function delete_file()
{
	if (confirm("真的删除？"))
	{
		var v = $("#file_list").val();
		var url = "new_app_form.php";
		var pars = { page_status: 3, acc: v };
		$.post(url, pars, function(text) {
			if (/成功/.test(text) || /Success/.test(text)) {
				$("#file_list").find("option[@value='" + v + "']").remove();
			}
			else { alert("删除失败！"); }
		});
		
	}
}
// 传送上传的文件
function add_acc()
{
	var fl = $("#file_list");
	var a = [];
	if (!$.trim(fl.html())) { window.opener.clearAccessory(); window.close(); return false; }
	fl.find("option").each(function(i) {
		a[a.length] = $(this).val();
	});
	window.opener.addAccessory(a.join(";;"));
	window.close();
}
// 从父窗口中获取附件数据
function get_acc()
{
	var acc_str = window.opener.getAccessory();
	if (!$.trim(acc_str)) { return false; }
	
	var accs = acc_str.split(";;");
	var str = "";
	$.each(accs, function(i, n) {
		var t = n.split("/");
		str += "<option value=\"" + n + "\">" + t[t.length - 1] + "</option>";
	});
	$("#file_list").html(str);
}
</script>
</head>
<body>
	<span style="font-weight:bold;">请上传文件：</span>
	<hr />
	<!-- <input id="upload" name="upload" type="file" /><br /> -->
	<iframe src="new_app_upfile.php"></iframe>
	<hr width="60%" />
	<p><strong>注意：</strong>
	  <ul>
		<li>每个文件大小不超过 5MB</li>
		<li>允许上传的文件格式为：<br />
		    gif, jpg, jpeg, png, bmp, doc, xls, ppt, txt, pdf, odt
		</li>
	  </ul>
	</p>
	<hr width="60%" />
	<table border="0" cellspacing="0" cellpadding="0"><tr>
	<td>
	  <select id="file_list" name="file_list" size="5"></select>
	</td>
	<td>
	  <input type="button" onclick="delete_file();" value="删   除" />
	  <br />
	  <input type="button" value="重命名" disabled="disabled" />
	  <br /><br />
	  <input type="button" onclick="add_acc();" value="确   定" />
	</td>
	</tr></table>
  <script language="javascript">
    get_acc();
  </script>
</body>
</html>
